<%@page import="java.sql.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="student.Student"%>
<%@page import="student.StudentDao"%>
<%@ page language="java" import="java.util.*,DBUtil.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>学生注册处理页面</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
   <%
   	request.setCharacterEncoding("utf-8");
   	String sname=request.getParameter("sname");
   	String sex=request.getParameter("sex");
   	String telephone=request.getParameter("telephone");
   	String qq=request.getParameter("qq");
   	String wechat=request.getParameter("wechat");
   	String gradeidString=request.getParameter("gradeid");
   	int gradeid=Integer.parseInt(gradeidString);
   	String enterdateString=request.getParameter("enterdate");
   	Date enterdate=DBUtil.utilDateFormatsqlDate(enterdateString);
   	String fromcity=request.getParameter("fromcity");
   	String birthdayString=request.getParameter("birthday");
   	Date birthday=DBUtil.utilDateFormatsqlDate(birthdayString);
   	String address=request.getParameter("address");
   	String pass=request.getParameter("pass");
   	String last_examString=request.getParameter("last_exam");
   	Date last_exam=DBUtil.utilDateFormatsqlDate(last_examString);
   	Student s=new Student(sname,sex,telephone,qq,wechat,
   	gradeid,enterdate,fromcity,birthday,address,pass,last_exam);
	StudentDao stuDao=new StudentDao();
	int result=stuDao.add(s);
	
	if(result==1)
	{
		response.sendRedirect("showAllStudents.jsp");
	}
	else{
	out.print("<h1>添加失败！</h1");
	}
    %>
  </body>
</html>